{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑会议</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">会议名字</label>
                            <div class="layui-input-block">
                                <input type="text" name="m_name" class="layui-input" value="{$info.m_name}" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">会议类型:</label>
                            <div class="layui-input-block">
                                <select name="m_type" lay-filter="role" disabled>
                                    <option value="1" {if $info.m_type==1}selected{/if}>线上会议</option>
                                    <option value="3" {if $info.m_type==3}selected{/if}>线下会议</option>
                                    <option value="2" {if $info.m_type==2}selected{/if}>孚玛会议</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择公司:</label>
                            <div class="layui-input-block">
                                <select {if $info.m_status != 1}disabled{/if} name="m_c_id" lay-search="" id="company"  lay-filter="company"  lay-verify="required">
                                    <option value="">---- 请选择公司 ----</option>
                                    {foreach name="coms" item="c"}
                                    <option value="{$c.c_id}" {$c_id == $c.c_id ? 'selected' : ''}>{$c.c_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {if $info.m_type==2}hidden{/if}">
                            <label class="layui-form-label">关联产品:</label>
                            <div class="layui-input-block">
                                <select {if $info.m_status != 1}disabled{/if} name="m_cp_id" lay-search="" id="company_product">
                                    <option value="">---- 请选择产品 ----</option>
                                    {foreach name="product" item="p"}
                                    <option value="{$p.cp_id}" {$info.m_cp_id == $p.cp_id ? 'selected' : ''}>{$p.cp_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">关联业务员:</label>
                            <div class="layui-input-block">
                                <select {if $info.m_status != 1}disabled{/if} name="m_user_id" lay-search="" id="company_user"  lay-verify="required">
                                    <option value="">---- 请选择业务员 ----</option>
                                    {foreach name="users" item="u"}
                                    <option value="{$u.user_id}" {$info.m_user_id == $u.user_id ? 'selected' : ''}>{$u.user_username}({$u.user_phone})</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">开始时间:</label>
                            <div class="layui-input-block">
                                <input type="text" name="m_start" value="{$info.m_start}" {if $info.m_status==1}onclick="wk.lay_date(this);"{/if} class="layui-input" lay-verify="required" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">结束时间:</label>
                            <div class="layui-input-block">
                                <input type="text" name="m_end" value="{$info.m_end}" {if $info.m_status==1}onclick="wk.lay_date(this);"{/if} class="layui-input" lay-verify="required" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {if $info.m_type==2}hidden{/if}" id="m_address">
                            <label class="layui-form-label">会议地址:</label>
                            <div class="layui-input-block">
                                <input type="text" style="width: 500px" {if $info.m_status != 1}disabled{/if} value="{$info.m_address}" placeholder="线上会议须填写http或https协议直播地址，线下会议填写实际参会地址" name="m_address" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">会议描述:</label>
                            <div class="layui-input-block">
                                <textarea style="height: 100px;width: 400px" name="m_desc" class="layui-input" lay-verify="required">{$info.m_desc}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="image_1">
                            <label class="layui-form-label">会议图片:</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del2" value="">
                                <input type="hidden" id="hid2" value="{$info.m_img}">
                                <input type="hidden" name="m_img" id="photo2" value="{$info.m_img}">
                                <div id="uploader2" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker2"></div>
                                            <p>或将图片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker2" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--pdf-->
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {$info.m_type==2 ? '' : 'hidden'}" id="image_2">
                            <label class="layui-form-label">会议文档:</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del3" value="">
                                <input type="hidden" id="hid3" value="{$info.m_files}">
                                <input type="hidden" name="m_files2" id="photo3" value="{$info.m_files}">
                                <div id="uploader3" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker3"></div>
                                            <p>或将文档拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker3" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--pdf end -->
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {$info.m_type==1 ? '' : 'hidden'}" id="pdf_2">
                            <label class="layui-form-label">讲义文件:</label>
                            <input type="hidden" name="m_files" id="lay-img" lay-verify="image" value="{$info.m_files}">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传PDF</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    文件地址:
                                    <div class="layui-upload-list" id="lay-list">
                                        {if $info.m_type != 3}
                                        {$info.m_files}
                                        {/if}
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {$info.m_type!=2 ? 'hidden' : ''}" id="m_nums">
                            <label class="layui-form-label">参会人数:</label>
                            <div class="layui-input-block">
                                <input {if $info.m_status != 1}disabled{/if} type="number" name="m_nums" min="1" value="{$info.m_nums}" class="layui-input" >
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {$info.m_type!=2 ? 'hidden' : ''}" id="m_upload">
                            <label class="layui-form-label">上传文档权限:</label>
                            <div class="layui-input-block">
                                <input type="radio" name="m_upload" value="1" title="全员" {if $info.m_upload==1}checked{/if} />
                                <input type="radio" name="m_upload" value="2" title="主持人" {if $info.m_upload==2}checked{/if} />
                            </div>
                        </div>
                        <input type="hidden" value="{$info.m_id}" name="m_id">
                        <input type="hidden" value="{$info.m_type}" id="m_type">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
</body>
</html>
<script>
    var n2 = wk.uploads({num:10,type:'png,jpg,jpeg',attr:2,status:'update'});
    function imgDel2(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n2);
    }
    var mtype = $('#m_type').val();
    if(mtype == 2){
        var n3 = wk.uploads({num:10,attr:3,mwwadd:2,type:'PDF,pdf',status:'update'}); //图片
        function imgDel3(e,obj,hid,del){
            wk.update_del(e,obj,hid,del,n3);
        }
    }
    wk.uploadImg({size:5,type:'PDF,pdf',url:"{:url('Upload/upload')}",video:2}); //文档
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('meetEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(company)', function(data){
            getUsersByCom(data.value);
        });
        function getUsersByCom(cid){
            $.ajax({
                url:"{:url('admin/Project/getUsers')}",
                dataType:"json",
                data:'cid='+cid,
                type:'post',
                success:function(res){
                    var opt = '';
                    $.each(res.msg,function(key,vo){
                        opt = opt+"<option value="+vo.user_id+">"+vo.user_username+"("+vo.user_phone+")</option>";
                    });
                    $("#company_user").empty();
                    $("#company_user").append('<option value="">---- 请选择业务员 ----</option>');
                    $("#company_user").append(opt);
                    form.render('select');
                    var opt = '';
                    $.each(res.product,function(key,vo){
                        opt = opt+"<option value="+vo.cp_id+">"+vo.cp_name+"</option>";
                    });
                    $("#company_product").empty();
                    $("#company_product").append('<option value="">---- 请选择产品 ----</option>');
                    $("#company_product").append(opt);
                    form.render('select');
                }
            })
        }
    });
</script>